PROJECTENGRAM

[REV] CCPROG1 COMPREHENSIVE FINALS REVIEWER

Tags: #◇Computer Science #◇CCPROG1 #◇C Programming #◇Reviewer #◇Finals


CCPROG1 Comprehensive Finals Reviewer

◇Overview

This reviewer consolidates the fundamental programming curriculum in C from CCPROG1: Logic Formulation and Introductory Programming. It spans the complete software development lifecycle, algorithmic logic formulation, flowcharts, variable typing, operators and expressions, modular decomposition with functions, control structures (selection and iteration), testing/debugging methodologies, and coding standards.


◇1. Core Syntax & Data Representation Matrix

ConceptSpecifier / SyntaxSize (x86-64)Range / Behavior
char%c1 byte−128-128 to 127127 (ASCII code)
int%d or %i4 bytes−231-2^{31} to 231−12^{31}-1 (approx ±2.14×109\pm 2.14 \times 10^9)
float%f4 bytes6-7 decimal digits precision
double%lf8 bytes15-17 decimal digits precision
Division /int / int vs float / intN/AInteger division truncates towards zero (7/2=37/2 = 3). Float division yields 3.53.5.
Modulo %a % bN/ARemainder of integer division; operands must be integral.

Operator Precedence Hierarchy (Highest to Lowest)

  1. Parentheses: ()
  2. Postfix / Unary: ++, --, +, -, !
  3. Multiplicative: *, /, %
  4. Additive: +, -
  5. Relational: <, <=, >, >=
  6. Equality: ==, !=
  7. Logical AND: && (Short-circuiting: evaluates right only if left is true)
  8. Logical OR: || (Short-circuiting: evaluates right only if left is false)
  9. Assignment: =, +=, -=, etc.

◇2. Modular Decomposition & Functions

In C, functions enforce encapsulation and procedural abstraction.

  • Pass-by-Value: C passes all primitive parameters by value. A local copy is allocated on the activation frame (call stack). Modifications to the formal parameter inside the callee do not affect the caller's actual arguments.
  • Scope & Storage Duration:
    • Block scope: Visible only within enclosing {}.
    • Function prototype: Declares return type and signature before main() so the compiler can perform type checking.

◇3. Control Flow Architecture

Selection Structures

  • if ... else if ... else: Evaluates sequential boolean conditions.
  • switch(expr): Evaluates integral expressions against constant labels. Requires explicit break; to prevent fallthrough.

Iterative Structures

  • while(condition): Pre-test loop. Executes 0 or more times.
  • for(init; condition; update): Deterministic count-controlled loop.
  • do ... while(condition);: Post-test loop. Guarantees execution at least once.

◇4. High-Yield Exam Checklist

  • Does integer division discard decimal portions? (5/2=25 / 2 = 2).
  • Does scanf("%d", &val) require an address-of operator &?
  • Did you avoid placing a semicolon after if(...) or while(...) loops?
  • Are loop boundary conditions checked for off-by-one errors (<< vs ≤\le)?
  • Are all accumulator variables (sum, count) initialized to zero before loops?
  • Does switch use integral types (int, char) and include default:?

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

What is the output of printf("%d", 14 / 4 * 4 + 14 % 4); in C?

Q2

Given int x = 5, y = 10;, what is the value of x after if (x > 3 || ++y < 12) executes?

Q3

What happens if a non-void function in C finishes execution without an explicit return statement?

Q4

Which loop structure is guaranteed to execute its loop body at least once?

Q5

In C, what is the effect of writing while (x = 0) instead of while (x == 0)?